package com.demo.boot.rest;

import com.demo.boot.entity.Student;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * @author root
 * @date 2021-04-27 13:23
 */
@RestController
@RequestMapping("test")
public class TestRest {

    @GetMapping("time")
    public LocalDateTime time(@RequestParam LocalDateTime time) {
        System.out.println("time = " + time);
        return time;
    }

    @GetMapping("time0")
    public Date time(@RequestParam Date time) {
        System.out.println("time = " + time);
        return time;
    }

    @GetMapping("time1")
    public String time(@RequestParam String time) {
        System.out.println("time = " + time);
        return time;
    }

    @PostMapping("add")
    public String add(@RequestBody Student student) {
        System.out.println("student = " + student);
        return "time2";
    }

    @GetMapping("get")
    public Student get() {

        return Student.builder()
                .age(11)
                .birth(LocalDate.now())
                .name("测试")
                .sex("男").build();
    }
}
